﻿using Abp.BackgroundJobs;
using Abp.Dependency;
using Abp.ObjectMapping;
using AVIS.OutBound.WizardAgent;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Hangfire;
using System.ComponentModel;

namespace AVIS.OutBound.CarGroups.Job
{
    [Queue("wizard")]
    public class WizardCarGroupsJob : BackgroundJob<WizardCarGroupsJobArgs>, ITransientDependency
    {
        #region 构造函数
        private readonly IObjectMapper _objectMapper;
        private readonly WizardVehAvailRateAgent _wizardVehAgent;

        public WizardCarGroupsJob(IObjectMapper objectMapper)
        {
            _objectMapper = objectMapper;
            _wizardVehAgent = new WizardVehAvailRateAgent();
        }
        #endregion  

        [DisplayName("同步车组并缓存（{0}）")]
        [Description("同步Wizard接口的车组信息并缓存")]
        [Queue("wizard")]
        public override void Execute(WizardCarGroupsJobArgs args)
        {
            // 从Wizard接口中获取车组信息
            var rs = _objectMapper.Map<CarGroupsRequest>(args);
            var response = _wizardVehAgent.GetCarGroups(rs);
        }
    }
}
